define(["jquery","template",
    "scprit/nutrition/app/departmentScheme/editScheme.servers.js",
    "scprit/nutrition/template/departmentScheme/editScheme.tpl.js"],
    function ($,template,$servers,tpl) {
    var ui = {};

    var drawSchemeDetail = function(data){
        return template("nutrition_schemeDetail",data);
    }
    var drawSchemeStages = function(data){
        return template("nutrition_schemeStages",data);
    }
    var drawStageCourses = function(data) {
        return template("nutrition_stageCourses",data);
    }
    var drawCourseList = function(data){
        return template("nutrition_courseList",data);
    }
    var drawTree = function(data){
        return template("nutrition_tree",data);
    }

    /**
     * 顶部营养方案信息
     */
    ui.schemeDetailInit = function(options){
        $("#" + options.id).html( tpl.init2() );
        var html = drawSchemeDetail(options.data);
        $("#" + options.id).html(html);
    };
    /**
     * 营养方案阶段名渲染
     */
    ui.schemeStagesInit = function(options){
        $("#" + options.id).html( tpl.init4() );
        var html = drawSchemeStages($servers.handleStages(options.list));
        $("#" + options.id).html(html);
    };
    /**
     * 营养方案阶段疗程
     */
    ui.stageCoursesInit = function(options){
        $("#" + options.id).html( tpl.init3() );
        var html = drawStageCourses($servers.handleStageCourses(options.list,options.stageId));
        $("#" + options.id).html(html);
    };
    /**
     * 疗程库
     */
    ui.courseListInit = function(options){
        $("#" + options.id).html( tpl.init5() );
        var html = drawCourseList(options);
        $("#" + options.id).html(html);
    };
    /**
     * 树状图
     */
    ui.treeInit = function (options) {
        $(options.id).html( tpl.init() );
        var html = drawTree(options);
        $(options.id).html(html);
    };

    return ui;
});